<?php
class UCAdapter{
    static private $self= null;
    static public function getConfig() {
        define('UC_API',        C('UC_API') );
        define('UC_CONNECT',    C('UC_CONNECT') );
        define('UC_DBHOST',     C('UC_DBHOST') );
        define('UC_DBUSER',     C('UC_DBUSER') );
        define('UC_DBPW',       C('UC_DBPW') );
        define('UC_DBNAME',     C('UC_DBNAME') );
        define('UC_DBCHARSET',  C('UC_DBCHARSET') );
        define('UC_DBTABLEPRE', C('UC_DBTABLEPRE') );
        define('UC_DBCONNECT',  C('UC_DBCONNECT') );
        define('UC_KEY',        C('UC_KEY') );
        define('UC_CHARSET',    C('UC_CHARSET') );
        define('UC_IP',         C('UC_IP') );
        define('UC_APPID',      C('UC_APPID') );
        define('UC_PPP',        C('UC_PPP') );
    }
    static public function &get(){
        //import('@.uc_client.config#inc','','.php');
        self::getConfig();
        import('@.uc_client_qsc.client','','.php');
        if (!self::$self){
            self::$self= new UCAdapter();
        }
        return self::$self;
    }
    /****
    * user
    */
    public function user_register($username,$password,$email,$questionid = '',$answer = ''){
        return uc_user_register($username,$password,$email ,$questionid,$answer);
    }
    public function user_login($username,$password,$isuid = 0,$checkques = 0,$questionid = '',$answer = '') {
        return uc_user_login($username,$password,$isuid,$checkques,$questionid,$answer);
    }
    public function user_synlogin($uid) {
        return uc_user_synlogin($uid);
    }
    public function user_synlogout() {
        return uc_user_synlogout();
    }
    public function user_edit($username,$oldpw,$newpw,$email,$ignoreoldpw = 0,$questionid = '',$answer = '') {
        return uc_user_edit($username,$oldpw,$newpw,$email,$ignoreoldpw,$questionid,$answer);
    }
    public function user_delete($uid) {
        return uc_user_delete($uid);
    }
    public function user_deleteavatar($uid) {
        return uc_user_deleteavatar($uid);
    }
    public function user_checkname($username) {
        return uc_user_checkname($username);
    }
    public function user_checkemail($email) {
        return uc_user_checkemail($email);
    }
    public function user_addprotected($username,$admin='') {
        return user_addprotected($username,$admin);
    }
    public function user_deleteprotected($username) {
        return uc_user_deleteprotected($username);
    }
    public function user_getprotected() {
        return uc_user_getprotected();
    }
    public function get_user($username,$isuid=0){
        return uc_get_user($username,$isuid);
    }
    public function user_getcredit($appid,$uid,$credit) {
        return uc_user_getcredit($appid,$uid,$credit);
    }
    /****
    * friend
    */
    public function friend_ls($uid,$page=1 ,$pagesize=10 ,$totalnum=10 ,$direction=0){
        return uc_friend_ls($uid,$page,$pagesize,$totalnum,$direction);
    }
    public function friend_add($uid , $friendid, $comment="") {
        return uc_friend_add($uid,$friendid,$comment);
    }
    public function friend_delete($uid , $friendids) {
        return uc_friend_delete($uid,$friendids);
    }
    public function friend_totalnum($uid , $direction=0) {
        return uc_friend_totalnum($uid,$direction);
    }
    public function friend_isfriend($uid, $friendids, $direction=0) {
        return uc_friend_isfriend($uid, $friendids, $direction);
    }
    /*****
    * pm接口
    */
    public function pm_location($uid ,$newpm){
        return uc_pm_location(uid ,newpm);
    }
    public function pm_checknew($uid,$more=0){
        return uc_pm_checknew($uid,$more);
    }
    public function pm_send($fromuid ,$msgto ,$subject ,$message ,
                            $instantly=1 ,$replypmid=0 ,$isusername=0){
        return uc_pm_send($fromuid ,$msgto ,$subject ,$message ,$instantly ,$replypmid ,$isusername);
    }
    public function pm_delete($uid ,$folder ,$pmids){
        return uc_pm_delete($uid ,$folder ,$pmids);
    }
    public function pm_deleteuser($uid ,$touids){
        return pm_deleteuser($uid ,$touids);
    }
    public function pm_readstatus($uid,$uids,$pmids = array(),$status = 0) {
        return uc_pm_readstatus($uid,$uids,$pmids,$status);
    }
    public function pm_list($uid,$page = 1,$pagesize = 10,$folder = 'inbox',$filter = 'newpm',$msglen = 0) {
        return uc_pm_list($uid,$page,$pagesize,$folder,$filter,$msglen);
    }
    public function pm_ignore($uid) {
        return uc_pm_ignore($uid);
    }
    public function pm_view($uid,$pmid,$touid = 0,$daterange = 1) {
        return uc_pm_view($uid,$pmid,$touid ,$daterange );
    }
    public function pm_viewnode($uid,$type = 0,$pmid = 0) {
        return uc_pm_viewnode($uid,$type ,$pmid );
    }
    /****/
    public function pm_blackls_get($uid) {
        return uc_pm_blackls_get($uid);
    }
    public function pm_blackls_set($uid,$blackls) {
        return uc_pm_blackls_set($uid,$blackls);
    }
    public function pm_blackls_add($uid,$username) {
        return uc_pm_blackls_add($uid,$username);
    }
    public function pm_blackls_delete($uid,$username) {
        return uc_pm_blackls_delete($uid,$username);
    }
    /****
    * 头像接口
    */
    public function avatar($uid,$type = 'virtual',$returnhtml = 1) {
        return uc_avatar($uid,$type,$returnhtml );
    }
    public function check_avatar($uid,$size = 'middle',$type = 'virtual') {
        return uc_check_avatar($uid,$size,$type);
    }
}
//$UC= UCAdapter;
?>